package map;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.function.BiConsumer;

//map嵌套list
public class MapTest2 {
    public static void main(String[] args) {
        HashMap<String, ArrayList<String>>province=new HashMap<>();
        ArrayList<String>arrayList1=new ArrayList<>();
        Collections.addAll(arrayList1,"无锡市","扬州市","南京市");
        ArrayList<String>arrayList2=new ArrayList<>();
        Collections.addAll(arrayList2,"武汉市","孝感市","荆州市");
        ArrayList<String>arrayList3=new ArrayList<>();
        Collections.addAll(arrayList3,"成都市","绵阳市","自贡市");
        province.put("江苏",arrayList1);
        province.put("湖北",arrayList2);
        province.put("四川",arrayList3);


        province.forEach(new BiConsumer<String, ArrayList<String>>() {
            @Override
            public void accept(String s, ArrayList<String> strings) {
                String out=s+"=";
                for (int i = 0; i <strings.size()-1 ; i++) {
                    out+=strings.get(i);
                    out+=",";
                }
                out+=strings.get(strings.size()-1);
                System.out.println(out);
            }
        });

    }
}
